package com.yxzr.youyou.retrofit;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * Created by 18354 on 2018-04-08.
 */

public class RetrofitUtils {
    private static final Retrofit.Builder builder;
    static {

        builder = new Retrofit.Builder().client(new OkHttpClient.Builder().build()).
                addCallAdapterFactory(RxJava2CallAdapterFactory.create()).
                addConverterFactory(GsonConverterFactory.create());
    }

    public static void buildBaseUrl(String baseUrl) {
        builder.baseUrl(baseUrl);
    }

    public static <T> T createService(Class<T> serviceClass){
        return builder.build().create(serviceClass);
    }
}
